const sequelize = require('sequelize')
const User = require('../db/model/User')

async function userLogin ({userName, password}) {
  const user = await User.findOne({
    where: {[sequelize.Op.and]: [{user: userName, pass: password}]},
    order: [
      ['id', 'desc']
    ]
  })
  return {
    user: user.dataValues
  }
}

module.exports = {
  userLogin
}
